<template>
  <component :is="components" />
</template>
<script>
export default {
  data() {
    return {
      components: null
    }
  },
  created() {
    const modules = import.meta.glob('@/views/**/*.vue')
    let components = null
    const dir = (this.$route.query.path.includes('/index') ? this.$route.query.path : this.$route.query.path + '/index')
    for (const path in modules) {
      if (path.includes(dir)) {
        components = () => modules[path]()
      }
    }
    if (!components) {
      this.$message.error('找不到该组件地址')
      return
    }
    this.components = components
  }
}
</script>
